<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/WEB-INF/template/basicTemplate.xhtml">

	<ui:define name="content">
		<h:inputHidden rendered="#{menuController.userRank != 0}" value="#{menuController.redirect()}"></h:inputHidden>
		<h:inputHidden value="#{menuController.setUrl(request.requestURL)}"></h:inputHidden>
		<h:inputHidden id="form1" rendered="#{menuController.userRank == 0}">
			<h:messages id="mess"
				styleClass="#{roomController.messageClass}"></h:messages> <h:form>
				<br></br> 
				<div class="center"><h:panelGrid columns="2"
					styleClass="roomtable">
					<h:outputText value="Address:" />
					<h:inputText styleClass="inputText" name="username" id="address"
						value="#{roomDTO.address}" size="18">
					</h:inputText>
	
					<h:outputText value="Number Of Stations:" />
					<h:inputText styleClass="inputText" name="nr" id="nr"
						value="#{roomDTO.numberOfStations}" size="18"
						converterMessage="Number of stations must be a number!">
						<f:convertNumber integerOnly="false" />
						<f:validateLongRange minimum="0"></f:validateLongRange>
					</h:inputText>
	
				</h:panelGrid>
				<div class="twobut"><h:commandButton styleClass="button"
					actionListener="#{roomController.addRoom}" value="Add Room">
					<f:ajax execute="address nr" render=":mess @form"></f:ajax>
				</h:commandButton></div>
				<br></br>
				<br></br>
				<h:panelGrid column="3" styleClass="roomtable">
					<h:dataTable id="table" value="#{roomController.roomList}"
						var="item" border="10" styleClass="templatetable center">
						<h:column>
							<f:facet name="header">
								<h:outputText value="Address" />
							</f:facet>
	
							<div align="center"><h:outputText value="#{item.address}" /></div>
						</h:column>
						<h:column>
							<f:facet name="header">
								<h:outputText value="Nr of stations" />
							</f:facet>
							<h:inputText id="nrS" styleClass="inputText" size="4"
								value="#{item.numberOfStations}"
								converterMessage="Number of stations must be a number!">
								<f:convertNumber integerOnly="false" />
								<f:validateLongRange minimum="0"></f:validateLongRange>
								<f:ajax render="nrVal" event="keyup"></f:ajax>
							</h:inputText>
						</h:column>
	
						<h:column>
							<f:facet name="header">
								<h:outputText value="Delete" />
							</f:facet>
							<h:selectManyCheckbox styleClass="inner-table"
								value="#{roomController.checkbox}">
								<f:selectItem itemLabel="Delete" itemValue="#{item.id}" />
							</h:selectManyCheckbox>
	
						</h:column>
						<h:outputText id="nrVal" value="#{item.numberOfStations}" />
					</h:dataTable>
	
				</h:panelGrid>
	
	
				<div class="twobut"><h:commandButton styleClass="button"
					actionListener="#{roomController.updateRooms}" value="Update Rooms">
					<f:ajax render=":mess @form"></f:ajax>
				</h:commandButton> <h:commandButton styleClass="button"
					actionListener="#{roomController.deleteRoom}" value="Delete Rooms" onclick="if (!confirm('Are you sure you want to continue?')) return false;">
				</h:commandButton></div>
				</div>
			</h:form>
		</h:inputHidden>
		
	</ui:define>

</ui:composition>

</html>